package com.kaifamiao.month04.day05;

public class Stack {

    Object[] elements;
    int count = 0;

    public Stack(){
        elements = new Object[10];
    }

    public Stack(int n) {
        if(n > 10)
            elements = new Object[n];
        elements = new Object[10];
    }

    public void push(char element){
        elements[count ++] = element;
    }

    public Object peek(){
        if (count == 0)
            return null;
        return elements[count];

    }

    public Object pop(){
        if(count == 0)
            return null;
        Object element = elements[count - 1];
        elements[-- count] = null;
        return element;
    }

    public boolean isEmpty(){
        return count == 0;
    }
}
